<?php
SESSION_START();
header("Content-Type:text/html; charset=utf-8");
require_once("../connectMysql/connetMysql.class.php");
$db=new connetMysql;
$con=$db->getConnect();
date_default_timezone_set('prc');

$newsid = 44;
$commentusername="";

$comment_content = $_POST['content'];
if(isset($_SESSION['userid'])){
	echo "1";
}
else{
	$commentusername="网友";
	$time = Date("Y-m-d H:i:s",time());
	$sql="INSERT INTO comment (commentnewsid, commentusername, commentcontent,commenttime)  VALUES    ('$newsid','$commentusername','$comment_content','$time')";
	if (!mysqli_query($con,$sql))
  	{
  		die('Error: ' . mysqli_error());
 	}
	$json = array('commentusername'=>  $commentusername,'time' =>  $time);
    echo json_encode($json);
}
?>